package io.zhifei.modules.app.login.utils;/**
 * <p>  </p>
 *
 * @author： WangPeng <br/>
 * @date： 2020/9/21$ 11:02$ <br/>
 * @version： <br/>
 */

import io.zhifei.modules.app.login.form.LoginForm;

import javax.servlet.http.HttpServletRequest;
import java.net.InetAddress;
import java.util.HashMap;
import java.util.Map;

/**
 * <p>  </p>
 *
 * @author： WangPeng <br/>
 * @date： 2020/9/21$ 11:02$ <br/>
 * @version： <br/>
 */
public class MACUtils {

    public static Map<String, String> MAC(HttpServletRequest request, LoginForm form) {
        String loginDevice = "";
        String MAC = "";
        try {
            if (UserAgenUtils.isComputer(request) == true) {
                loginDevice = "PC";
                InetAddress ia = InetAddress.getLocalHost();
                MAC = PCMacUtils.getLocalMac(ia);
            } else if (UserAgenUtils.isMobile(request) == true) {
                loginDevice = "Mob";
                MAC = form.getMAC();
            } else if (UserAgenUtils.isTablet(request) == true) {
                loginDevice = "Tab";
                MAC = form.getMAC();
            }

            Map<String, String> map = new HashMap<>();
            map.put("loginDevice", loginDevice);
            map.put("MAC", MAC);
            return map;
        } catch (Exception e) {
            return null;
        }
    }
}
